package com.blog.common.newclass.dostringabs;

import com.blog.common.newclass.inteface.DoStr;

/**
 * 加密：隐藏字符串后面四个字符
 */
public class DoEntryLast extends DoEntryAbs {

    public static final int LAST_NUM = 3;
    public static final String REPLASE_STR = "**";

    public DoEntryLast(DoStr doStr){
        super(doStr);
    }

    @Override
    public String getStr() throws Exception{
        String source = super.getStr();
        if (source.length() <= LAST_NUM)
            return REPLASE_STR;
        source = source.substring(0, source.length()- LAST_NUM);
        return source.concat(REPLASE_STR);
    }

    @Override
    public int cost() {
        return super.cost()+1;
    }

}